﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Flame.Dlr;
using System.Text.RegularExpressions;

namespace Flame.Reflection
{
    public class CSharpIntellisense : AIntellisense
    {

        IntellisenseParsing _regex, _regexM;
        public CSharpIntellisense(IExecutable compiler)
            : base(compiler)
        {
            _regex = IntellisenseParsing.RegexBuilder(@"", @"\.", @"[a-zA-Z0-9_]");
            _regexM = IntellisenseParsing.RegexBuilder(@"", @"\.", @"[a-zA-Z0-9_]", @"\([^\)]*");
        }

        protected override IntellisenseParsing IntellisenseParsing_Method { get { return _regexM; } }
        protected override IntellisenseParsing IntellisenseParsing_Type { get { return _regex; } }

       


        protected override Type InstanceTypeFromName(string word)
        {
            return (Type)_compiler.Execute("(" + word + ").GetType()").Data;
        }

        protected override Type ClassTypeFromName(string word)
        {
            return (Type)_compiler.Execute("typeof(" + word + ")").Data;
        }

        protected override string[] ClassTypeFromName_More(string word)
        {
            return new string[]{};
        }

        protected override string[] Split(string word)
        {
           return word.Split('.');
        }
        protected override string Clean(string word)
        {
            return word.TrimEnd('.');
        }
    }
}
